package o2o.system;

import com.jinyou.utils.common.ValidateUtil;
import notice.buzz.NoticeBusiness;
import o2o.business.sms.UserSMSInfoParams;
import o2o.cache.sys.SysConfigVerifyMemory;
import o2o.cache.system.SysSettingCategoryMemory;
import o2o.cache.system.SysSettingMemory;
import o2o.config.dao.UserDaoSql;
import o2o.config.dao.utils.DaoUtils;
import o2o.config.dao.utils.Expression;
import o2o.config.dao.utils.QueryCondition;
import o2o.dao.PO.PojoTables;
import o2o.dao.PO.release.ReleaseInformationMongo;
import o2o.dao.PO.sys.SysConfigMongoDb;
import o2o.dao.PO.sys.SysConfigRun;
import o2o.system.data.SYS_CONFIG_RUN;
import o2o.system.data.SYS_SETTINGS;

import o2o.task.shop.ShopStatisticsPreDayTask;
import verify.aliyun.RPBasicUtils;

import java.sql.SQLException;
import java.util.List;
import java.util.Optional;

//系统配置
public class SysSettings {


    //初始化系统配置
    public static void init() {
        SysSettingCategoryMemory.getInstance().reload();
        SysSettingMemory.getInstance().run();
        Integer utilTemp = null;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasShowSellCount");
        SYS_SETTINGS.HAS_SHOW_SELL_COUNT = utilTemp == null ? 0 : utilTemp; // 是否有显示
        SYS_SETTINGS.OPEN_EXACT_USER_TYPE = SysSettingMemory.getInstance().getValueByCode("openExactUserType"); //是否打开精确权限 1 是 0 否
        SYS_SETTINGS.DAO_DIAN_VERIFY_LENGTH = SysSettingMemory.getInstance().getValueByCode("daoDianVerifyLength");//到店提货码长度
        //是否开启系统黑名单
        SYS_SETTINGS.SYS_BLACK_LIST_OPEN = SysSettingMemory.getInstance().getValueByCode("sysBlackListOpen");//开启系统黑名单 1开启 0不开启

        SYS_SETTINGS.CITY_VERSION = SysSettingMemory.getInstance().getValueByCode("cityVersion");//城市版本号
        SYS_SETTINGS.USER_REGISTER_NEED_CODE = SysSettingMemory.getInstance().getValueByCode("userRegisterNeedCode");//用户注册是否需要验证码
        SYS_SETTINGS.BUSINESS_RATE = SysSettingMemory.getInstance().getValueByCode("businessRate");//业务员分成比例 百分比
        SYS_SETTINGS.PLATE_SHARE_SYS_CITY_ADMIN_RATE = SysSettingMemory.getInstance().getValueByCode("plateShareSysCityAdminRate");//平台抽取城代比例 百分比
        SYS_SETTINGS.SHOP_RATE_PEISONG = SysSettingMemory.getInstance().getValueByCode("shopRatePeisong");//配送单店铺分成比例 百分比
        SYS_SETTINGS.SHOP_RATE_DAODIAN = SysSettingMemory.getInstance().getValueByCode("shopRateDaodian");//到店单店铺分成比例 百分比
//        SYS_SETTINGS.POSTMAN_RATE = SysSettingMemory.getInstance().getValueByCode("postmanRate");//骑手分成比例 百分比
        SYS_SETTINGS.PLATFORM_RATE_PEISONG = SysSettingMemory.getInstance().getValueByCode("platformRatePeisong");//配送单平台分成比例 百分比
        SYS_SETTINGS.HAS_SHOP_ZIQU_SHARE = Optional.ofNullable(SysSettingMemory.getInstance().getValueByCode("hasShopZiQuShare")).orElse(0);// 是否有自取订单分成比例设置
        SYS_SETTINGS.HAS_ZIQU_AWARD = Optional.ofNullable(SysSettingMemory.getInstance().getValueByCode("hasZiQuAward")).orElse(0);// 是否有自取折扣
        SYS_SETTINGS.PLATFORM_RATE_DAODIAN = SysSettingMemory.getInstance().getValueByCode("platformRateDaodian");//到店单平台分成比例 百分比
        SYS_SETTINGS.IS_SYS_CITY_ADMIN_SHARE_MONEY = SysSettingMemory.getInstance().getValueByCode("isSysCityAdminShareMoney");//城代是否参与分成（0不参与 1只有店铺和平台方式，2平台统一设置，最后金额归属平台，3店铺的直属代理是最大受益人,4除直属代理参与配送费分成，其他代理不参与配送费分成）
        SYS_SETTINGS.PLAT_SHARE_CITY_ADMIN_MONEY_TYPE = SysSettingMemory.getInstance().getValueByCode("platShareCityAdminMoneyType");//平台抽取城代分成比例方式(0不抽取，1抽取订单总金额部分，2抽取配送费部分，3抽取支付金额部分)

        SYS_SETTINGS.AGENT_IS_SHOP = SysSettingMemory.getInstance().getValueByCode("agentIsShop");//代理是一个店铺 修改代理信息或商户信息时联动  1 联动   0 不联动
        SYS_SETTINGS.ADD_GOODS_NEED_CHECK_UPC = SysSettingMemory.getInstance().getValueByCode("addGoodsNeedCheckUPC");//编辑商品的时候，是否需要判断统一商品编码（1需要，0不需要）


        //新建店铺是否需要自动加载基础商品或分类
        SYS_SETTINGS.AUTO_ADD_BASE_GOODS_CATEGORY = SysSettingMemory.getInstance().getValueByCode("autoAddBaseGoodsCategory");//新建店铺时，自动添加基础商品分类（1需要，0不需要）
        SYS_SETTINGS.AUTO_ADD_BASE_GOODS = SysSettingMemory.getInstance().getValueByCode("autoAddBaseGoods");//新建店铺时，自动添加基础商品（1需要，0不需要）
        SYS_SETTINGS.BASE_GOODS_IS_GOODS = SysSettingMemory.getInstance().getValueByCode("baseGoodsIsGoods");//基础商品修改时，商品也跟着修改 1是 0不是


        SYS_SETTINGS.PAY_CHECK_SHOP_STATUS = SysSettingMemory.getInstance().getValueByCode("payCheckShopStatus");//支付时检测店铺是否营业中  1检测  0不检测

        //配送员管理
        SYS_SETTINGS.POSTMAN_IN_CITY_OR_AGENT = SysSettingMemory.getInstance().getValueByCode("postmanInCityOrAgent");//配送员管理方式 是按城市还是按代理  1按城市 2按代理
        SYS_SETTINGS.POSTMAN_GARB_ORDER_BEFORE_SHOP = SysSettingMemory.getInstance().getValueByCode("postmanGrabOrderBeforeShop");//配送员是否可以在商家接单前抢单  1商家接前可以抢，0接单前不可以抢

        //店铺管理方式
        SYS_SETTINGS.SHOP_MANAGE_TYPE = SysSettingMemory.getInstance().getValueByCode("shopManageType");//店铺管理方式 自由的城市模式（例如奇惠购），还是精确的代理模式（例如云送） 1自由模式 2精确模式
        //店铺默认密码方式
        SYS_SETTINGS.SHOP_DEFAULT_PSW = SysSettingMemory.getInstance().getValueByCode("shopDefaultPSW");//店铺默认密码 1默认后6位 0默认123456

        SYS_SETTINGS.SHOP_MUST_DEPOSIT = SysSettingMemory.getInstance().getValueByCode("shopMustDeposit");//店铺必须缴纳押金才能使用 0无需缴纳  1必须缴纳
        SYS_SETTINGS.SHOP_NOW_POSITION_NEED = SysSettingMemory.getInstance().getValueByCode("shopNowPositionNeed");//需要店铺的实时位置 0不需要  1需要
        SYS_SETTINGS.LOCAL_CITY_AGENT_TYPE = SysSettingMemory.getInstance().getValueByCode("localCityAgentType");//定位时城市按下商圈列表还是单独商圈  1单独商圈，0商圈列表

        SYS_SETTINGS.SHOP_VERFY_ISPEISONG = SysSettingMemory.getInstance().getValueByCode("shopVerfyIsPeiSong");//审核时店铺是否配送 1配送 0不配送
        SYS_SETTINGS.SHOP_VERFY_ISDAODIAN = SysSettingMemory.getInstance().getValueByCode("shopVerfyIsDaoDian");//审核时店铺是否到店 1到店 0不到店
        SYS_SETTINGS.SHOP_VERFY_ISSELFPOST = SysSettingMemory.getInstance().getValueByCode("shopVerfyIsSelfPost");//审核时店铺配送方式 1自配送 0平台配送
        SYS_SETTINGS.SHOP_AUTO_APPLY_BY_PLATFORM = SysSettingMemory.getInstance().getValueByCode("shopAutoApplyByPlatform");//平台为店铺自动接单  0不自动接  1自动接
        SYS_SETTINGS.AUTO_UP_DOWN_WORK_MODEL = SysSettingMemory.getInstance().getValueByCode("autoUpDownWorkModel");//自动上下班模式：0全时段自动上下班，1只上下班时间点处理
        SYS_SETTINGS.SERIES_SHOP_LIMIT_ONE_AGENT = SysSettingMemory.getInstance().getValueByCode("seriesShopLimitOneAgent");//每个商圈下代理个数限制 -1不限
        utilTemp = SysSettingMemory.getInstance().getValueByCode("shopBelongMultipleAgent");
        SYS_SETTINGS.SHOP_BELONG_MULTIPLE_AGENT = Optional.ofNullable(utilTemp).isPresent() ? utilTemp : 0; //店铺属于多个商圈 0 一个  多个
        SYS_SETTINGS.USER_ADDRESS_IS_AGENT = SysSettingMemory.getInstance().getValueByCode("userAddressIsAgent");//用户的收货地址 就是选择的代理 1直接选代理 0普通地址

        SYS_SETTINGS.GOODS_ORDER_NOT_SURE_SHOP = SysSettingMemory.getInstance().getValueByCode("goodsOrderNotSureShop");//外卖订单提交的时候商家是不确定的 0不确定 1确定

        //配送员每天可转单次数
        SYS_SETTINGS.POSTMAN_CAN_CHANGE_COUNT_PRE_DAY = SysSettingMemory.getInstance().getValueByCode("postmanCanChangeCountPreDay");//配送员每天可转单次数
        SYS_SETTINGS.POSTMAN_CAM_GRAB_ORDER = SysSettingMemory.getInstance().getValueByCode("postmanCanGrabOrder");//配送员可抢订单数量 -1不限
        SYS_SETTINGS.POSTMAN_MUST_VERIFY = SysSettingMemory.getInstance().getValueByCode("postmanMustVerify");//配送员必须认证才能使用 0无需认证 1必须认证
        SYS_SETTINGS.POSTMAN_MUST_DEPOSIT = SysSettingMemory.getInstance().getValueByCode("postmanMustDeposit");//配送员必须缴纳押金才能使用 0无需缴纳 1必须缴纳
        SYS_SETTINGS.CHECK_POSTMAN_GRAB_RANGE = SysSettingMemory.getInstance().getValueByCode("checkPostmanGrabRange");//验证配送员抢单范围 0不验证 1验证取货地址 2验证收货地址
        SYS_SETTINGS.POSTMAN_MONEY_SCORE = SysSettingMemory.getInstance().getValueByCode("postmanMoneyScore");//配送员积分计算规则 10代表10元1积分
        SYS_SETTINGS.POSTMAN_MUST_VERIFY_FACE = SysSettingMemory.getInstance().getValueByCode("postmanMustVerifyFace");//配送员必须人脸实名认证才能使用 0无需认证 1必须认证
        SYS_SETTINGS.POSTMAN_LIKE_IS_FIRST = SysSettingMemory.getInstance().getValueByCode("postManLikeIsFirst"); // 下单后优先派给收藏骑手或司机 0 不是 1 是
        SYS_SETTINGS.LIKE_POSTMAN_UNROB_TIME = SysSettingMemory.getInstance().getValueByCode("likePostmanUnRobTime"); // 收藏的骑手不接单多久后，其他骑手可以接单
        utilTemp = SysSettingMemory.getInstance().getValueByCode("postmanCanBackCountPreDay");
        SYS_SETTINGS.POSTMAN_CAN_BACK_COUNT_PRE_DAY = utilTemp == null ? 0 : utilTemp;// 配送员每天退单次数
        utilTemp = SysSettingMemory.getInstance().getValueByCode("postmanCanBackTime"); //  配送员多少分钟内可以退单
        SYS_SETTINGS.POSTMAN_CAN_BACK_TIME = utilTemp == null ? 0 : utilTemp;

        SYS_SETTINGS.DELIVERY_RANGE = SysSettingMemory.getInstance().getValueByCode("deliveryRange");//配送范围 公里(km)
        SYS_SETTINGS.SHOP_RANGE = SysSettingMemory.getInstance().getValueByCode("shopRange");//配送范围 公里(km)
        SYS_SETTINGS.SYS_TYPE = SysSettingMemory.getInstance().getValueByCode("sysType");//系统类型 1标准版、2专业版、3企业版
        SYS_SETTINGS.PAOTUI_SYS_CAL_MONEY = SysSettingMemory.getInstance().getValueByCode("paotuiSysCalMoney");//跑腿代购是否接口计算一下价格  1计算 0不计算
        SYS_SETTINGS.PAOTUI_TIP_INFO_AGENT = SysSettingMemory.getInstance().getValueByCode("paotuiTipInfoAgent");//跑腿使用的重量等是否可以按商圈设置  1按商圈 0全平台统一
        utilTemp = SysSettingMemory.getInstance().getValueByCode("isElectronicFence");//商圈是否启用电子围栏模式:  0普通模式 1电子围栏模式  2使用店铺的电子围栏
        SYS_SETTINGS.IS_ELECTRONIC_FENCE = Optional.ofNullable(utilTemp).isPresent() ? utilTemp : 0;
        SYS_SETTINGS.DELIVERY_DISTANCE_IS_NOT_CHECK = SysSettingMemory.getInstance().getValueByCode("deliveryDistanceIsNotCheck");// 不验证配送距离 1不验证  0 验证
        SYS_SETTINGS.SHOP_BIND_WALLET_CARD_NEED_CHECK = SysSettingMemory.getInstance().getValueByCode("shopBindWalletCardNeedCheck");// 是否开启商家银行卡绑定校验 1开启,0不开启
        SYS_SETTINGS.NO_SHOP_SHOW_DEFAULT = SysSettingMemory.getInstance().getValueByCode("noShopShowDefault");//获取不到店铺时，显示默认店铺  1显示 0不显示
        SYS_SETTINGS.SHOW_SPECIAL_SHOP = SysSettingMemory.getInstance().getValueByCode("showSpecialShop");// 是否显示特殊店铺 0不显示 1显示
        SYS_SETTINGS.SHARE_GOODS_CAN_PULL_MULTI = SysSettingMemory.getInstance().getValueByCode("shareGoodsCanPullMulti");//商品分享，分享商品后，可领取多个商品  1可多个  0不可多个
        utilTemp = SysSettingMemory.getInstance().getValueByCode("serviceTelUseAdmin");// 关于我们服务电话使用代理的0 默认 1 使用代理的
        SYS_SETTINGS.SERVICE_TEL_USE_ADMIN = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasGoodsDistribute");// 是否有商品分销 0 没有 1 有
        SYS_SETTINGS.HAS_GOODS_DISTRIBUTE = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("wxAliUseTri");// 微信支付宝使用中间第三方 0系统内部 1SynoPay 2nexi 4nihaopay 7EasyEuro
        SYS_SETTINGS.WX_ALI_USE_TRI = utilTemp == null ? 0 : utilTemp;

        SYS_SETTINGS.SHOP_WALLET_POP_MONTH = SysSettingMemory.getInstance().getValueByCode("shopWalletPopMonth");//商户每月提现次数限制
        SYS_SETTINGS.SHOP_WALLET_POP_WEEK = SysSettingMemory.getInstance().getValueByCode("shopWalletPopWeek");//商户每周提现次数限制
        SYS_SETTINGS.SHOP_WALLET_POP_MONEY = SysSettingMemory.getInstance().getValueByCode("shopWalletPopMoney");//商户每次提现金额限制


        SYS_SETTINGS.APPOINT_AFTER_DATE = SysSettingMemory.getInstance().getValueByCode("appointAfterDate");//可预约天数
        SYS_SETTINGS.APPOINTMENT_DATE = SysSettingMemory.getInstance().getValueByCode("appointmentDate");//可预约到店消费天数

        utilTemp = SysSettingMemory.getInstance().getValueByCode("defaultMinuteLater");// 只能下多久以后的订单
        SYS_SETTINGS.DEFAULT_MINUTE_LATER = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("userMultipleOfHundred");// 提现倍数
        SYS_SETTINGS.USER_MULTIPLE_OF_HUNDRED = utilTemp == null || utilTemp <= 0 ? 0 : utilTemp;
        SYS_SETTINGS.SHOP_SHARE_DELIVERY_MONEY = SysSettingMemory.getInstance().getValueByCode("shopShareDeliveryMoney");//店铺是否分成配送费部分（1参与，0不参与）
        SYS_SETTINGS.POSTMAN_SHARE_MONEY = SysSettingMemory.getInstance().getValueByCode("postmanShareMoney");//配送员是否参与分成（0不参与，1总金额，2参与配送费部分,3按商圈设置的配送员工资结算公式计算）
        SYS_SETTINGS.POSTMAN_SHARE_DAIGOU_GOODS_MONEY = SysSettingMemory.getInstance().getValueByCode("postmanShareDaigouGoodsMoney");//配送员分成代购商品金额部分  -1都给骑手  0全部给平台

        utilTemp = SysSettingMemory.getInstance().getValueByCode("shareShopPacketMoney");
//        SYS_SETTINGS.SHARE_SHOP_PACKET_MONEY = SysSettingMemory.getInstance().getValueByCode("shareShopPacketMoney");//打包费是否参与分成  1参与 0不参与(都归店铺所有)
        SYS_SETTINGS.SHARE_SHOP_PACKET_MONEY = Optional.ofNullable(utilTemp).isPresent() ? utilTemp : 0;//打包费是否参与分成  1参与 0不参与(都归店铺所有)

        //订单相关
        SYS_SETTINGS.AWARD_AND_SALE_MODEL = SysSettingMemory.getInstance().getValueByCode("awardAndSaleModel");//商品折扣与满减：0满减和折扣能够同时使用，1只能使用折扣，2只能使用满减，3根据用户选择其一处理
        SYS_SETTINGS.ORDER_COMMIT_TYPE = SysSettingMemory.getInstance().getValueByCode("orderCommitType");// 订单评价方式 0默认评价形式店铺骑手商品单独评价 1一次性提交评价即结束
        SYS_SETTINGS.POSTMAN_NEW_ORDER_SORT = SysSettingMemory.getInstance().getValueByCode("postmanNewOrderSort");// 骑手新订单排序 0默认排序最新订单在最上面   1最新订单在最下面
        utilTemp = SysSettingMemory.getInstance().getValueByCode("postmanIngOrderSort");// 骑手进行中排序 0默认排序最新订单在最上面   1最新订单在最下面
        SYS_SETTINGS.POSTMAN_ING_ORDER_SORT = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("orderCommentDefaultDay");// 多少天未评论的订单系统会默认评论 0 永远不会
        SYS_SETTINGS.ORDER_COMMENT_DEFAULT_DAY = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("orderCommentNeedVerify");// 订单评论是否需要审核
        SYS_SETTINGS.ORDER_COMMENT_NEED_VERIFY = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasReduceDeliveryPriceGame");// 是否有满减配送费活动
        SYS_SETTINGS.HAS_REDUCE_DELIVERY_PRICE_GAME = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("isHasPrintOrderShopNote");// 订单打印小票是否有商家备注功能 0 没有  1 有
        SYS_SETTINGS.IS_HAS_PRINT_ORDER_SHOP_NOTE = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasMultipleOrder");// 是否有聚合订单 0 没有 1 有
        SYS_SETTINGS.HAS_MULTIPLE_ORDER = Optional.ofNullable(utilTemp).isPresent() ? utilTemp : 0;
        SYS_SETTINGS.MONEY_POP_TIMES = SysSettingMemory.getInstance().getValueByCode("moneyPopTimes");//每月提现次数限制
        SYS_SETTINGS.MONEY_POP_TIMES_WEEK = SysSettingMemory.getInstance().getValueByCode("moneyPopTimesWeek");//每周提现次数限制
        SYS_SETTINGS.MONEY_POP_TIMES_PRE = SysSettingMemory.getInstance().getValueByCode("moneyPopTimesPre");//每次提现金额限制

        SYS_SETTINGS.LIMIT_POP_TYPE = SysSettingMemory.getInstance().getValueByCode("limitPopType");//限制提现方式: 1 按次数 2 按日期 3 按次数和日期


        SYS_SETTINGS.URGENT_DELIVERY_PRICE = SysSettingMemory.getInstance().getValueByCode("urgentDeliveryPrice");//加急单额外运费
        SYS_SETTINGS.ORDER_MEMORY_DAYS = SysSettingMemory.getInstance().getValueByCode("orderMemoryDays");// 订单加载多少天内的  空或者-1为全部
        SYS_SETTINGS.IS_OPEN_AUTO_DISPATCH_ORDER = SysSettingMemory.getInstance().getValueByCode("isOpenAutoDispatchOrder");// 是否开启自动派单功能  0不开启，1开启
        SYS_SETTINGS.POSTMAN_MAX_ORDER_NUM = SysSettingMemory.getInstance().getValueByCode("postmanMaxOrderNum");// 骑手最多可接单数量
        utilTemp = SysSettingMemory.getInstance().getValueByCode("canUrgeOrderTime");
        SYS_SETTINGS.CAN_URGE_ORDER_TIME = utilTemp == null ? 0 : utilTemp;// 多长时间以后可以催单时间,单位分钟
        utilTemp = SysSettingMemory.getInstance().getValueByCode("awardCanExceedPrice");
        SYS_SETTINGS.AWARD_CAN_EXCEED_PRICE = utilTemp == null ? 0 : utilTemp;// 满减金额可以超过订单总价格 0 不可以  1 可以

        SYS_SETTINGS.SHOP_DEFAULT_STAR = SysSettingMemory.getInstance().getValueByCode("shopDefaultStar");//店铺默认星级

        utilTemp = SysSettingMemory.getInstance().getValueByCode("orderOnlyShowToday");//订单只显示当天 1 是 0 不是
        SYS_SETTINGS.ORDER_ONLY_SHOW_TODAY = utilTemp == null ? 0 : utilTemp; // 订单只显示当天的
        SYS_SETTINGS.ORDER_AUTO_FINISH_TIME = SysSettingMemory.getInstance().getValueByCode("orderAutoFinishTime");//配送完成或已到店消费后，间隔多久订单自动完成
        SYS_SETTINGS.ORDER_AUTO_CANCEL_TIME = SysSettingMemory.getInstance().getValueByCode("orderAutoCancelTime");//商家多久不接单后，自动取消订单（分钟）  -1不自动取消
        SYS_SETTINGS.ORDER_PAID_IS_OVER = SysSettingMemory.getInstance().getValueByCode("orderPaidIsOver");//订单支付成功是否为已完成 1支付成功即完成 0正常订单流程
        SYS_SETTINGS.SHOP_ING_ORDER_OVER_TYPE = SysSettingMemory.getInstance().getValueByCode("shopIngOrderOverType");//商家进行中订单包含类型  1配送员取走即从商家进行中去除 0配送员取走继续留在进行中（目前只有等我5分钟的是配送员取走还保留在进行中，因为配送和商家是同一个端）
        SYS_SETTINGS.GOODS_CATALOG_SORT_BY_ORDER_NO = SysSettingMemory.getInstance().getValueByCode("goodsCatalogSortByOrderNo");//店铺首页商品类别按排序编号排序  1按排序编号排序  0默认排序
        utilTemp = SysSettingMemory.getInstance().getValueByCode("goodsSortOrderNoMaxTop");//店铺首页商品编号排序  1 降序  0默认升序
        SYS_SETTINGS.GOODS_SORT_ORDER_NO_MAX_TOP = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasFreeGoods");// 是否有免单商品
        SYS_SETTINGS.HAS_FREE_GOODS = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasCompanyGoods");// 是否有企业商品
        SYS_SETTINGS.HAS_COMPANY_GOODS = utilTemp == null ? 0 : utilTemp;
        SYS_SETTINGS.IS_SHOW_ZHE_KOU_TIP = SysSettingMemory.getInstance().getValueByCode("isShowZhekouTip");//商品是否显示折扣标识  1显示 0不显示
        SYS_SETTINGS.IS_BACK_PACKET_PRICE = SysSettingMemory.getInstance().getValueByCode("isBackPacketPrice");//部分商品退款 在商家备货完成后是否退还部分商品包装费 0 不退换 1退还

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasBrowseHistory");// 是不是有浏览记录的
        SYS_SETTINGS.HAS_BROWSE_HISTORY = utilTemp == null ? 0 : utilTemp; //

        utilTemp = SysSettingMemory.getInstance().getValueByCode("orderExportIsAddShare");// 订单导出是否导出分成信息
        SYS_SETTINGS.ORDER_EXPORT_IS_ADD_SHARE = utilTemp == null ? 0 : utilTemp; //
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasLastOnlineTime");// 是否有最后在线时间
        SYS_SETTINGS.HAS_LAST_ONLINE_TIME = utilTemp == null ? 0 : utilTemp; //
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasMemberRecharge");// 是否有会员充值功能
        SYS_SETTINGS.HAS_MEMBER_RECHARGE = utilTemp == null ? 0 : utilTemp; //
//        SYS_SETTINGS.ORDER_DELIVERY_TIME = SysSettingMemory.getInstance().getValueByCode("orderDeliveryTime");// 订单配送时间 单位分钟
//        SYS_SETTINGS.ALERT_ABOUT_TIMEOUT_TIME = SysSettingMemory.getInstance().getValueByCode("alertAboutTimeoutTime");// 即将超时提醒时间 单位分钟
        SYS_SETTINGS.IS_CHECK_ORDER_OVERTIME = SysSettingMemory.getInstance().getValueByCode("isCheckOrderOvertime");  // 是否开启订单超时时间检测 1 开启 0不开启
        utilTemp = SysSettingMemory.getInstance().getValueByCode("agentManagerIsShareMoney");  // 区域主管是不是分钱 0 不分钱 1 分钱
        SYS_SETTINGS.AGENT_MANAGER_IS_SHARE_MONEY = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("grabOrderMode"); // 0 混合模式 1 仅抢单模式 2 仅调度模式
        SYS_SETTINGS.GRAB_ORDER_MODE = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("adminManagerGrabOrderMode"); // 0 混合模式 1 仅抢单模式 2 仅调度模式
        SYS_SETTINGS.ADMIN_MANAGER_GRAB_ORDER_MODE = utilTemp == null ? 0 : utilTemp; // 代理是否能够管理抢单模式 1 能 0 不能

        utilTemp = SysSettingMemory.getInstance().getValueByCode("adminManagerDispatchOrderMode"); // 管理员是否可以管理调度模式
        SYS_SETTINGS.ADMIN_MANAGER_DISPATCH_ORDER_MODE = utilTemp == null ? 0 : utilTemp; //
        //推送相关
        SYS_SETTINGS.IS_PUSH_WITH_GZH = SysSettingMemory.getInstance().getValueByCode("isPushWithGzh");//是否开启微信公众号推送 1开启 0不开启
        SYS_SETTINGS.IS_PUSH_WITH_JPUSH = SysSettingMemory.getInstance().getValueByCode("isPushWithJPush");//是否开启极光推 1开启 0不开启
        SYS_SETTINGS.IS_PUSH_WITH_JPUSH_2_USER = SysSettingMemory.getInstance().getValueByCode("isPushWithJPush2User");//是否将订单通过极光，推送给用户 1推 0不推
        SYS_SETTINGS.IS_PUSH_WITH_JPUSH_2_SHOP = SysSettingMemory.getInstance().getValueByCode("isPushWithJPush2Shop");//是否将订单通过极光，推送给商家 1推 0不推
        SYS_SETTINGS.IS_PUSH_WITH_JPUSH_2_POSTMAN = SysSettingMemory.getInstance().getValueByCode("isPushWithJPush2Postman");//是否将订单通过极光，推送给配送 1推 0不推

        //短信验证码相关
        SYS_SETTINGS.SHOP_NEW_ORDER_SMS = SysSettingMemory.getInstance().getValueByCode("shopNewOrderSMS");//店铺有新订单发送短信提醒 1发送 0不发送
        SYS_SETTINGS.SHOP_NEW_ORDER_PHONE = SysSettingMemory.getInstance().getValueByCode("shopNewOrderPhone");// 店铺有新订单是否电话通知  -1不通知  未接单分钟数
        SYS_SETTINGS.SHOP_ONLINE = SysSettingMemory.getInstance().getValueByCode("shopOnline");// 店铺是否在线统计
        utilTemp = SysSettingMemory.getInstance().getValueByCode("updateShopGoodsCount");// 更新店铺的商品个数显示 好管家在使用
        SYS_SETTINGS.UPDATE_SHOP_GOODS_COUNT = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("postmanServiceShop");// 是否是骑手服务店铺模式
        SYS_SETTINGS.POSTMAN_SERVICE_SHOP = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("isShopPaotui");// 是不是商家跑腿
        SYS_SETTINGS.IS_SHOP_PAOTUI = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasBaoXian");// 是否有保险
        SYS_SETTINGS.HAS_BAO_XIAN = utilTemp == null ? 0 : utilTemp;
        //小志
        SYS_SETTINGS.IS_HAS_DEVICE_DOOR = SysSettingMemory.getInstance().getValueByCode("isHasDeviceDoor");//是否有门禁模块 1有 0没有
        SYS_SETTINGS.DOOR_REFRESH_TIME = SysSettingMemory.getInstance().getValueByCode("doorRefreshTime");// 门禁刷新的时间（分钟）
        SYS_SETTINGS.IS_NEED_REGISTER_JY_SERVICE = SysSettingMemory.getInstance().getValueByCode("isNeedRegisterJYService");//是否注册小志微服务用户 1需要 0不需要

        //配送费计算方式
        SYS_SETTINGS.SELECT_DISTRIBUTION_FEE = SysSettingMemory.getInstance().getValueByCode("selectDistributionFee");//配送费计算方式 1固定配送费 2按距离计算

        //分销
        SYS_SETTINGS.IS_OPEN_DISTRIBUTION = SysSettingMemory.getInstance().getValueByCode("isOpenDistribution");//是否开启分销 0不开启 1开启

        // 小费分成
        SYS_SETTINGS.SHARE_TIP_MONEY = SysSettingMemory.getInstance().getValueByCode("shareTipMoney"); // 小费分成（0 ：店铺所有 1 ：骑手所有 2 ：店铺按比例 3店铺和骑手均按比例 4 骑手按比例 5 均无）

        // 税率
        SYS_SETTINGS.IS_SHARE_TAX_MONEY = SysSettingMemory.getInstance().getValueByCode("isShareTaxMoney"); // 税是否参与分成

        SYS_SETTINGS.PLATFORM_TAX_RATE = SysSettingMemory.getInstance().getValueByCode("platformTaxRate"); // 平台设置税
        utilTemp = SysSettingMemory.getInstance().getValueByCode("taxCalculationType"); // 0 没有税费  1 按照金额计算 2 按照单个商品计算
        SYS_SETTINGS.TAX_CALCULATION_TYPE = Optional.ofNullable(utilTemp).orElse(0);
        SYS_SETTINGS.SHOP_AUTO_POP = SysSettingMemory.getInstance().getValueByCode("shopAutoPop"); // 系统自动提现

        SYS_SETTINGS.SHOP_AUTO_POP_TYPE = SysSettingMemory.getInstance().getValueByCode("shopAutoPopType"); // 商家自动提现方式 1 每指定天数检测一次 2 每天检测指定天数后提现 0 未开启

        utilTemp = SysSettingMemory.getInstance().getValueByCode("shopAutoHotSellCount"); // 店铺热销产品数量 即大于多少自动标注产品为店铺的热销产品
        SYS_SETTINGS.SHOP_AUTO_HOT_SELL_COUNT = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("shopAutoNewGoodsDay"); // 自动新品 即商品上架多少天内会自动标注为新品
        SYS_SETTINGS.SHOP_AUTO_NEW_GOODS_DAY = utilTemp == null ? 0 : utilTemp;
        // 是否开启支付密码
        SYS_SETTINGS.VERIFY_PAYMENT_PASSWORD = SysSettingMemory.getInstance().getValueByCode("verifyPaymentPassword"); // 0 不开启  1：开启

        //汇率换算
        String exchangeRate = SysSettingMemory.getInstance().getValueStrByCode("exchangeRate");//汇率换算 1美元=6.8205人民币
        if (ValidateUtil.isNotNull(exchangeRate)) {
            SYS_SETTINGS.EXCHANGE_RATE = Double.parseDouble(exchangeRate);
        } else {
            SYS_SETTINGS.EXCHANGE_RATE = 1d;
        }
        SYS_SETTINGS.CURRENCY_UNIT = SysSettingMemory.getInstance().getValueStrByCode("currencyUnit");//主货币单位
        SYS_SETTINGS.USE_MAIN_CURRENCY_PAY = SysSettingMemory.getInstance().getValueByCode("useMainCurrencyPay");// 支付是否需要汇率换算 0需要换算 1不需要换算
        SYS_SETTINGS.USE_MAIN_CURRENCY_POP = SysSettingMemory.getInstance().getValueByCode("useMainCurrencyPop");// 提现是否使用汇率换算0需要换算 1不需要换算

        //多语言
        SYS_SETTINGS.HAS_MULTILINGUAL = SysSettingMemory.getInstance().getValueByCode("hasMultilingual");//是否启用多语言 0不启用  1启用
        SYS_SETTINGS.SHOP_LIST_GET_BY_LAT_LNG = SysSettingMemory.getInstance().getValueByCode("shopListGetByLatLng");//店铺列表是否按经纬度获取  0按城市  1按经纬度

        // 是否支持货到付款
        utilTemp = SysSettingMemory.getInstance().getValueByCode("isCashOnDelivery"); // 0 不不支持  1：支持
        SYS_SETTINGS.IS_CASH_ON_DELIVERY = utilTemp == null ? 0 : utilTemp; // 0 不不支持  1：支持

        // 是否使用微服务的红包
        utilTemp = SysSettingMemory.getInstance().getValueByCode("useServiceRedPacket");
        SYS_SETTINGS.USE_SERVICE_RED_PACKET = utilTemp == null ? 0 : utilTemp;// 0 不使用 1 使用

        utilTemp = SysSettingMemory.getInstance().getValueByCode("arrivePayIsDistribute");
        SYS_SETTINGS.ARRIVE_PAY_IS_DISTRIBUTE = utilTemp == null ? 0 : utilTemp;// 货到付款是否分成
        // 是否更新库存
        SYS_SETTINGS.AUTO_UPDATE_STOCK = SysSettingMemory.getInstance().getValueByCode("autoUpdateStock"); // 0 不使用 1 使用

        // 是否区分非批发商品,0,不区分，1区分并显示非批发商品
        SYS_SETTINGS.NO_WHOLESALE_GOODS = SysSettingMemory.getInstance().getValueByCode("noWholesaleGoods");

        SYS_SETTINGS.SHOP_WORKER_RATE = SysSettingMemory.getInstance().getValueByCode("shopWorkerRate"); // 店铺工人分成比例
        utilTemp = SysSettingMemory.getInstance().getValueByCode("isPlateGoodsDrawMoney");
        SYS_SETTINGS.IS_PLATE_GOODS_DRAW_MONEY = utilTemp == null ? 0 : utilTemp;// 是否单个商品抽成 0 不抽成 1 抽成

        utilTemp = SysSettingMemory.getInstance().getValueByCode("postmanChouyongType");
        SYS_SETTINGS.POSTMAN_CHOUYONG_TYPE = utilTemp == null ? 0 : utilTemp;// 配送员抽佣方式 0 默认方式 1 按照线路抽佣

        // 是否有最小金额
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasMinShopMoney");
        SYS_SETTINGS.HAS_MIN_SHOP_MONEY = utilTemp == null ? 0 : utilTemp;

        SYS_SETTINGS.SELL_COUNT_TYPE = SysSettingMemory.getInstance().getValueByCode("sellCountType"); // 销量类型0：月销量1：总销量

        // 是否启用原材料
        SYS_SETTINGS.USE_ORIGINAL_MATERIAL = SysSettingMemory.getInstance().getValueByCode("useOriginalMaterial"); //  0 不是用该显示 1 使用
        SYS_SETTINGS.IS_AUTO_ZHE_KOU_GOOD = SysSettingMemory.getInstance().getValueByCode("isAutoZhekouGood"); // 是否自动折扣 1现价比原价低就是折扣商品 0手动设置折扣
        utilTemp = SysSettingMemory.getInstance().getValueByCode("zhekouNotJoinFeeYunfei");
        SYS_SETTINGS.ZHEKOU_NOT_JOIN_FEE_YUNFEI = utilTemp == null ? 0 : utilTemp; //   折扣不参与假面配送费 0 参与 1不参与
        // 是否使用新版界面
        SYS_SETTINGS.IS_NEW_VERSION_PAGE = SysSettingMemory.getInstance().getValueByCode("isNewVersionPage"); // 0 使用旧版界面 1 使用新版界面

        SYS_SETTINGS.IS_HAS_COMMUNITY_GROUP_ACTIVE = SysSettingMemory.getInstance().getValueByCode("isHasCommunityGroupActive"); //是否有社区团购活动模块 1有 0没有

        // 积分抵用的百分比
        SYS_SETTINGS.INTEGRAL_PERCENT = SysSettingMemory.getInstance().getValueByCode("integralPercent"); //积分抵用的百分比

        // 跑腿上下班设置
        SYS_SETTINGS.PAOTUI_WORK_SETTING = SysSettingMemory.getInstance().getValueByCode("paotuiWorkSetting"); //跑腿上下班设置

        // 是否使用积分模块
        SYS_SETTINGS.IS_OPEN_INTEGRAL = SysSettingMemory.getInstance().getValueByCode("isOpenIntegral"); // 0 没有 1 有

        // 是否有营销场景
        SYS_SETTINGS.IS_HAS_MARKET_SCENE = SysSettingMemory.getInstance().getValueByCode("isHasMarketScene"); // 0 没有 1 有

        SYS_SETTINGS.BASE_GAME_IS_DEL = SysSettingMemory.getInstance().getValueByCode("baseGameIsDel"); //  基础活动删除时，店铺对应的活动是否跟随删除
        utilTemp = SysSettingMemory.getInstance().getValueByCode("goodsCategoryIsDel"); //分类删除时  对应的下一级分类和商品是否删除 1删除 0 不删除
        SYS_SETTINGS.GOODS_CATEGORY_IS_DEL = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("distinguishShopRecommend"); // 是否区分商家推荐 0 不区分 1 区分 // 区分的话 外卖推荐和团购推荐不一样
        SYS_SETTINGS.DISTINGUISH_SHOP_RECOMMEND = utilTemp == null ? 0 : utilTemp;

        SYS_SETTINGS.WATERMARK_CONTENT = SysSettingMemory.getInstance().getValueStrByCode("watermarkContent");  // 水印内容
        utilTemp = SysSettingMemory.getInstance().getValueByCode("informationMustVerify");  // 便民信息需要审核
        SYS_SETTINGS.INFORMATION_MUST_VERIFY = utilTemp == null ? 0 : utilTemp;
        SYS_SETTINGS.HOME_PAGE_TIP = SysSettingMemory.getInstance().getValueStrByCode("homePageTip");  // 首页提示信息

        utilTemp = SysSettingMemory.getInstance().getValueByCode("bmBrowseForOnece");  // 一次访问次数
        SYS_SETTINGS.BM_BROWSE_FOR_ONECE = (utilTemp == null || utilTemp <= 0) ? 1 : utilTemp; // 便民信息访问次数
        utilTemp = SysSettingMemory.getInstance().getValueByCode("lifeInfoBrowseShopType");  // 便民信息-浏览量展示方式
        SYS_SETTINGS.LIFE_INFO_BROWSE_SHOW_TYPE = (utilTemp == null || utilTemp <= 0) ? 1 : utilTemp; // 便民信息-浏览量展示方式

        SYS_SETTINGS.IS_WEIGHT_ADD_DELIVERY = SysSettingMemory.getInstance().getValueByCode("isWeightAddDelivery"); // 重量是否参与计算

        SYS_SETTINGS.IS_UPPER_LOWER_SYSADMIN = SysSettingMemory.getInstance().getValueByCode("isUpperLowerSysAdmin"); // 是不是上下级代理模式 1 上下级代理模式

        SYS_SETTINGS.IS_DISCOUNT_GOODS_MONEY = SysSettingMemory.getInstance().getValueByCode("isDiscountGoodsMoney"); // 折扣是商品金额 1 商品金额 0 总金额
        SYS_SETTINGS.SYSTEM_OPERATE_NOT_NEED_ACCEPT = SysSettingMemory.getInstance().getValueByCode("systemOperateNotNeedAccept"); // 派单转单 等是不是需改骑手接受 1 不需要 0 需要

        SYS_SETTINGS.RED_PACKET_INVALID_AUTO_DEL = SysSettingMemory.getInstance().getValueByCode("redPacketInvalidAutoDel"); // 红包过期是否自动删除 1 自动删除 0 不自动删除
        SYS_SETTINGS.RED_PACKET_INVALID_DAYS_AUTO_DEL = SysSettingMemory.getInstance().getValueByCode("redPacketInvalidDaysAutoDel"); // 红包过期后 几天删除 0 立即删除 1 过期一天后自动删除

        SYS_SETTINGS.ASSIGN_ORDER_CAN_REPEATEDLY = SysSettingMemory.getInstance().getValueByCode("assignOrderCanRepeatedly"); // 指派订单是否可以多次 1 可以 0不可以
        utilTemp = SysSettingMemory.getInstance().getValueByCode("orderCanPartCancelMulti"); // 订单是否可以被多次部分取消 1 可以 0 不可以
        SYS_SETTINGS.ORDER_CAN_PART_CANCEL_MULTI = utilTemp == null ? 0 : utilTemp;
        SYS_SETTINGS.NO_NEED_REFUNDS_AFTER_SHOP_SURE = SysSettingMemory.getInstance().getValueByCode("noNeedRefundsAfterShopSure"); // 商家接单后多少秒无需审核 0 必须审核 1一秒内
        SYS_SETTINGS.HAS_ZHEKOU_TIMING = SysSettingMemory.getInstance().getValueByCode("hasZhekouTiming"); // 有没有折扣商品定时功能 0没有 1有
        SYS_SETTINGS.PRINT_STYLE_TYPE = SysSettingMemory.getInstance().getValueByCode("printStyleType"); // 打印机打印样式 1本系统 2美团模式
        SYS_SETTINGS.IS_PRINT_QR_CODE = SysSettingMemory.getInstance().getValueByCode("isPrintQRCode"); // 是否打印二维码 0 不打印 1 打印

        SYS_SETTINGS.PRINT_NEW_ORDER_INSTRUCTION = SysSettingMemory.getInstance().getValueStrByCode("printNewOrderInstruction"); // 打印机附加新订单指令

        SYS_SETTINGS.PRINT_CANCEL_ORDER_APPLY_INSTRUCTION = SysSettingMemory.getInstance().getValueStrByCode("printCancelOrderApplyInstruction"); // 申请退款指令

        SYS_SETTINGS.LOGIN_TYPE_BY = SysSettingMemory.getInstance().getValueByCode("loginTypeBy"); // 登录类型 0 按照username登录 1 按照手机号登录

        SYS_SETTINGS.IS_SYSADMIN_CREATE_COMPANY = SysSettingMemory.getInstance().getValueByCode("isSysadminCreateCompany"); // 是否为代理创建公司 0 不创建 1 创建

        SYS_SETTINGS.HAS_SHOP_TYPE_OPEN = SysSettingMemory.getInstance().getValueByCode("hasShopTypeOpen"); //  是否有店铺类别开关 0 没有 1 有

        SYS_SETTINGS.IS_ELECTRONICFENCE = SysSettingMemory.getInstance().getValueByCode("isElectronicFence"); //  商圈是否启用电子围栏模式:  0普通模式 1电子围栏模式

        utilTemp = SysSettingMemory.getInstance().getValueByCode("thirdPartyCompany"); //  是不是第三方的开发模式 0 不是 1是
        SYS_SETTINGS.THIRD_PARTY_COMPANY = utilTemp == null ? 0 : utilTemp;

        SYS_SETTINGS.CUSTOMIZE_ORDER_TYPE = SysSettingMemory.getInstance().getValueByCode("customizeOrderType"); //  是不是自定义订单类型  0 不是 1是

        utilTemp = SysSettingMemory.getInstance().getValueByCode("customSystemType");
        SYS_SETTINGS.CUSTOM_SYSTEM_TYPE = Optional.ofNullable(utilTemp).isPresent() ? utilTemp : 0; //  定制系统类型 0 外卖系统 1 配送系统类型（如一乙）

        SYS_SETTINGS.SYSTEM_TEST = SysSettingMemory.getInstance().getValueByCode("systemTest"); //

        SYS_SETTINGS.SHOP_SELF_POST_NO_SHARE_PACKET = SysSettingMemory.getInstance().getValueByCode("shopSelfPostNoSharePacket"); // 商家自配送订单不分成打包费 0 分成 1 不分成

        utilTemp = SysSettingMemory.getInstance().getValueByCode("userBakOrder"); //  是否启动自动备份订单访问机制  0不启用 1启用
        SYS_SETTINGS.USE_BAK_ORDER = utilTemp == null ? 1 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("sysSOSModel"); // 系统应急模式 0不使用应急模式 1屏蔽管理后台数据库查询  2屏蔽管理后台已完成、全部订单数据库查询  3屏蔽管理后台，订单总个数
        SYS_SETTINGS.SYS_SOS_MODEL = utilTemp == null ? 0 : utilTemp;


        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasGoodsPriceTime"); //  是否有商品价格设置
        SYS_SETTINGS.HAS_GOODS_PRICE_TIME = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasGoodsPriceNumber"); //  是否有商品数量价格设置
        SYS_SETTINGS.HAS_GOODS_PRICE_NUMBER = utilTemp == null ? 0 : utilTemp;


        SYS_SETTINGS.SYSTEM_RUN_TIME = SysSettingMemory.getInstance().getValueStrByCode("systemRunTime"); // 系统运营时间段
        utilTemp = SysSettingMemory.getInstance().getValueByCode("shopAutoCloseMode"); // 店铺自动上下班模式  1 原来的默认 2 商家上班会自动开启自动上下班功能，停止营业会关闭自动自动上下班
        SYS_SETTINGS.SHOP_AUTO_CLOSE_MODE = utilTemp == null ? 1 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("runningDistanceRate"); //  跑腿距离比例单位(%) 0 默认未设置比例 120 则 距离是原来的1.2倍
        SYS_SETTINGS.RUNNING_DISTANCE_RATE = utilTemp == null ? 0 : utilTemp;
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasTransferWxAli"); //  是不是有转账的线上转账的功能
        SYS_SETTINGS.HAS_TRANSFER_WX_ALI = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasAgentPay");
        SYS_SETTINGS.HAS_AGENT_PAY = utilTemp == null ? 0 : utilTemp; // 是否有代付的功能
        utilTemp = SysSettingMemory.getInstance().getValueByCode("isOtherPost");
        SYS_SETTINGS.IS_OTHER_POST = utilTemp == null ? 1 : utilTemp; //  是不是哒哒配送
        utilTemp = SysSettingMemory.getInstance().getValueByCode("managerPostmanNeedVerify");
        SYS_SETTINGS.MANAGER_POSTMAN_NEED_VERIFY = utilTemp == null ? 0 : utilTemp; //  管理后台添加的配送员是否需要认证 0 不需要 1  需要
        utilTemp = SysSettingMemory.getInstance().getValueByCode("isRidingDistance");
        SYS_SETTINGS.IS_RIDING_DISTANCE = utilTemp == null ? 0 : utilTemp; //  是否按照实际骑行距离进行计算配送费  1 是 0 否
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasMinBuyCount");
        SYS_SETTINGS.HAS_MIN_BUY_COUNT = utilTemp == null ? 0 : utilTemp; //  是否有最小限购  1 是 0 否
        utilTemp = SysSettingMemory.getInstance().getValueByCode("shopHasPayFinishPacket");
        SYS_SETTINGS.SHOP_HAS_PAY_FINISH_PACKET = utilTemp == null ? 0 : utilTemp; //   是否有店铺红包
        utilTemp = SysSettingMemory.getInstance().getValueByCode("distributionModel");
        SYS_SETTINGS.DISTRIBUTION_MODEL = utilTemp == null ? 0 : utilTemp; //   分销模式  0全民分销 1 部分分销
        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasDistributePopToWallet");
        SYS_SETTINGS.HAS_DISTRIBUTE_POP_TO_WALLET = utilTemp == null ? 0 : utilTemp; //   是否有分销提到到余额 1 有 0 没有
        utilTemp = SysSettingMemory.getInstance().getValueByCode("paotuiHasCarType");
        SYS_SETTINGS.PAOTUI_HAS_CAR_TYPE = utilTemp == null ? 0 : utilTemp; //   跑腿是否有车型区分
        utilTemp = SysSettingMemory.getInstance().getValueByCode("squareOrderIsAutoApply");
        SYS_SETTINGS.SQUARE_ORDER_IS_AUTO_APPLY = utilTemp == null ? 0 : utilTemp; //   创业商圈订单是否自动接单

        // 2020年4月13日 10:33:45  Jahnke
        SYS_SETTINGS.REMOTE_IMAGE_STATE = SysSettingMemory.getInstance().getValueByCode("remoteImgUrlState");       // 是否启用远程图片服务 1-启用 0-不启用

        utilTemp = SysSettingMemory.getInstance().getValueByCode("imageSaveAnotherSever");
        SYS_SETTINGS.IMAGE_SAVE_ANOTHER_SERVER = utilTemp == null ? 0 : utilTemp;       // 图片存在其他服务器 1其他服务器 0本地服务器
        // 店铺抽佣方式
        utilTemp = SysSettingMemory.getInstance().getValueByCode("shopChouYongModel");  // 店铺抽佣方式 0 默认 1 按照阶梯固定抽成
        SYS_SETTINGS.SHOP_CHOU_YONG_MODEL = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("orderFinishBackDuty");  // 店铺抽佣方式 0 默认 1 按照阶梯固定抽成
        SYS_SETTINGS.ORDER_FINISH_BACK_DUTY = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("deliveryTimeByDistance");  // 是否按照距离设置配送时长 1 是 0 不是
        SYS_SETTINGS.DELIVERY_TIME_BY_DISTANCE = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasDeliveryWorkDays");  // 是否有配送日
        SYS_SETTINGS.HAS_DELIVERY_WORK_DAYS = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasHomeRecommend");  // 是否有首页推荐
        SYS_SETTINGS.HAS_HOME_RECOMMEND = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("cityLineFeeUseDistance");  // 线路费用使用距离进行计算
        SYS_SETTINGS.CITY_LINE_FEE_USE_DISTANCE = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("cityLineFeeCalculateType");  // 线路费用计算方式  1 线路基础费用*人数 + 增值费用 0 (基础费用+线路费用) * 人数
        SYS_SETTINGS.CITY_LINE_FEE_CALCULATE_TYPE = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("orderGoodsSorts");  // 订单商品是否排序
        SYS_SETTINGS.ORDER_GOODS_SORTS = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("orderAddressShowCity");  // 订单商品是否排序
        SYS_SETTINGS.ORDER_ADDRESS_SHOW_CITY = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("agentManagerDaiGou");  //  代购是否按照商圈区分
        SYS_SETTINGS.AGENT_MANAGER_DAI_GOU = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("cityAdminManagerBianMin");  //  城市代理是否能够管理便民信息
        SYS_SETTINGS.CITY_ADMIN_MANAGER_BIANMIN = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("userOrderCanSearch");  //  用户订单是否可以搜索
        SYS_SETTINGS.USER_ORDER_CAN_SEARCH = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("postingCancelStatisticsFinish");  //  骑手配送    取消订单是否算入已完成订单统计
        SYS_SETTINGS.POSTING_CANCEL_STATISTICS_FINISH = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("lockShopIsLockUser");  //  锁定商户的时候是否锁定用户
        SYS_SETTINGS.LOCK_SHOP_IS_LOCK_USER = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasRequiredGoodsCategory");  //  是否有必选商品分类
        SYS_SETTINGS.HAS_REQUIRED_GOODS_CATEGORY = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("notPayAutoCancelOrderTime");  //  未支付自动取消订单时间
        SYS_SETTINGS.NOT_PAY_AUTO_CANCEL_ORDER_TIME = (ValidateUtil.isAbsInteger(utilTemp) && utilTemp > 0) ? utilTemp : 30; // 默认30分钟

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasOrderRefuseDelShopPostman");  //  有订单的话拒绝删除店铺以及骑手
        SYS_SETTINGS.HAS_ORDER_REFUSE_DEL_SHOP_POSTMAN = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("cityAdminCanManagePacket");  //  代理是否可以管理红包
        SYS_SETTINGS.CITY_ADMIN_CAN_MANAGE_PACKET = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasOrderSecondPostmanVerifyCode");  //  订单是否有二级骑手验证码
        SYS_SETTINGS.HAS_ORDER_SECOND_POSTMAN_VERIFY_CODE = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasPaoTuiOrderTimeSet");  // 跑腿订单是否记录骑手超时设置
        SYS_SETTINGS.HAS_PAOTUI_ORDER_TIME_SET = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("paotuiOrderRefundNoNeedVerify");  // 跑腿订单退款不需要审核 1 不需要 0 需要
        SYS_SETTINGS.PAOTUI_ORDER_REFUND_NO_NEED_VERIFY = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("locationAgentOnlyShowAgentBanner");  // 定位到商圈只显示商圈轮播图
        SYS_SETTINGS.LOCATION_AGENT_ONLY_SHOW_AGENT_BANNER = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasShopJoinVipGameManager");  // 管理店铺参与vip会员活动 0 全都可以 1 根据商家独立设置
        SYS_SETTINGS.HAS_SHOP_JOIN_VIP_GAME_MANAGER = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("shopCommentShowAfterMinute");  // 店铺评论在多长时间之后显示 -1 不设置 0 不设置 单位分钟
        SYS_SETTINGS.SHOP_COMMENT_SHOW_AFTER_MINUTE = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("autoFinishChangePostmanTime");  // 骑手操作转单后,多长时间无操作自动完成转单
        SYS_SETTINGS.AUTO_FINISH_CHANGE_POSTMAN_TIME = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("isOpenShopSettlement");  // 是否开启账单结算 0 不开启  直接到账 1 开启账单结算
        SYS_SETTINGS.IS_OPEN_SHOP_SETTLEMENT = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasMuchShopOrderSet");  // 是否有多店铺订单设置 0 全部 1 自己设置店铺 2 全部支持
        SYS_SETTINGS.HAS_MUCH_SHOP_ORDER_SET = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("groupOrderExpiredAutoCancel");  // 团购券过期自动取消 1 自动取消 0 不自动取消
        SYS_SETTINGS.GROUP_ORDER_EXPIRED_AUTO_CANCEL = utilTemp == null ? 0 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("newUserOrderDiscountRate");  // 折扣 新用户折扣百分比 0 免单   50 则打五折 -1不打折
        SYS_SETTINGS.NEW_USER_ORDER_DISCOUNT_RATE = utilTemp == null ? -1 : utilTemp;

        utilTemp = SysSettingMemory.getInstance().getValueByCode("isOpenDiscountExchangeCode");  // 是否开启折扣兑换码
        SYS_SETTINGS.IS_OPEN_DISCOUNT_EXCHANGE_CODE = utilTemp == null ? -1 : utilTemp;

        SYS_SETTINGS.LOCAL_PROJECT_TIME_ZONE = SysSettingMemory.getInstance().getValueStrByCode("localProjectTimeZone");  // 项目运行时区

        utilTemp = SysSettingMemory.getInstance().getValueByCode("defaultQueryOrderInDay");  // 默认管理后台订单管理 - 查询数据库中多长时间内的订单
        SYS_SETTINGS.DEFAULT_QUERY_ORDER_IN_DAY = utilTemp == null ? 0 : utilTemp;
        // 骑手分成比例 百分比
        try {
            String val = SysSettingMemory.getInstance().getValueStrByCode("postmanRate");   // 骑手分成比例 百分比
            SYS_SETTINGS.POSTMAN_RATE = ValidateUtil.isNull(val) ? null : Double.parseDouble(val);
        } catch (Exception e) {
            e.printStackTrace();
            SYS_SETTINGS.POSTMAN_RATE = null;
        }
        // 最小抽成金额
        try {
            String temp = SysSettingMemory.getInstance().getValueStrByCode("minWithdrawalAmount");
            SYS_SETTINGS.MIN_WITHDRAWAL_AMOUNT = Double.parseDouble(ValidateUtil.isNull(temp) ? 0.0 + "" : temp);
        } catch (Exception e) {
            System.out.println("最小抽成金额错误");
        }

        utilTemp = SysSettingMemory.getInstance().getValueByCode("hasRecommendHotZheKouGoodsList");  //  是否有推荐, 热销, 折扣的商品列表
        SYS_SETTINGS.HAS_RECOMMEND_HOT_ZHEKOU_GOODS_LIST = utilTemp == null ? 0 : utilTemp;

        initMongoDb();//初始化mongodb配置
        initRunnable();//初始化线程相关
        initVerify();//加载实名认证配置
    }


    //初始化短信相关
    private static void initMongoDb() {
        System.out.println("----------初始化mongodb配置--");
        QueryCondition query = QueryCondition.getInstance();
        query.addCondition(Expression.getInstance().addChild("delFlag", 0));//所有未删除的
        String sql = DaoUtils.getSql(PojoTables.SYS_CONFIG_MONGODB, query);
        SysConfigMongoDb info = null;
        try {
            info = (SysConfigMongoDb) UserDaoSql.getInstance().getObject(SysConfigMongoDb.class, sql);
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println("初始化短信服务配置失败");
        }

        if (null == info) {
            System.out.println("未配置短信服务，请联系系统管理员");
        }
        UserSMSInfoParams.MonUserSMSDB = info.getUserMsgDb();
        System.out.println("短信库：" + UserSMSInfoParams.MonUserSMSDB);

        // 便民信息库
        ReleaseInformationMongo.informationMongoDB = info.getInformationDb();
        System.out.println("便民信息库：" + ReleaseInformationMongo.informationMongoDB);

        NoticeBusiness.noticeMainDB = info.getNoticeMainDb();
        NoticeBusiness.noticeUserDB = info.getNoticeUserDb();
        System.out.println("消息主库：" + NoticeBusiness.noticeMainDB);
        System.out.println("消息辅库：" + NoticeBusiness.noticeUserDB);

        ReleaseInformationMongo.onlineLogMongoDB = info.getOnlineLogDb();
        System.out.println("在线日志库：" + ReleaseInformationMongo.onlineLogMongoDB);


        // if (null != info.getServiceId()) {
        //     // SMSThreadMap.serviceId = info.getServiceId();
        // }

        System.out.println("----------mongodb配置初始化结束--");
    }


    //初始化线程相关
    private static void initRunnable() {
        System.out.println("----------初始化需要启动的线程--");
        QueryCondition query = QueryCondition.getInstance();
        query.addCondition(Expression.getInstance().addChild("delFlag", 0));//所有未删除的
        String sql = DaoUtils.getSql(PojoTables.SYS_CONFIG_RUN, query);
        List<SysConfigRun> list = null;
        try {
            list = (List<SysConfigRun>) UserDaoSql.getInstance().list(SysConfigRun.class, sql);
        } catch (SQLException e) {
            e.printStackTrace();
            System.out.println("初始化需要启动的线程失败");
        }

        if (ValidateUtil.isAbsList(list)) {
            for (int i = 0; i < list.size(); i++) {
                SysConfigRun info = list.get(i);
                if (null == info) {
                    continue;
                }
                if (ValidateUtil.isNull(info.getCode())) {
                    continue;
                }
                if (null == info.getNeedStart()) {
                    continue;
                }
                if (info.getNeedStart() <= 0) {
                    continue;
                }
                switch (info.getCode()) {
                    case SYS_CONFIG_RUN.TCP_SERVER_LIGHT_XZ: {//小志灯光TCP服务
                        // TCPServer_XZ.getInstance().open();
                        System.out.println("小志的线程启动了");
                    }
                    break;
                    case SYS_CONFIG_RUN.AUTO_UP_DOWN_WORK: {//是否开启自动上下班 1开启，0不开启
                        ShopStatisticsPreDayTask.isRun = true;
                        System.out.println("自动上下班线程启动了");
                    }
                    break;
                }
            }
        }


        System.out.println("----------初始化需要启动的线程结束--");
    }

    //加载实名认证配置
    private static void initVerify() {
        SysConfigVerifyMemory.getInstance().run(); //加载验证信息
        RPBasicUtils.init();
    }
}
